package xunlian;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int year = sc.nextInt();
			int year1 = 0;
			int year2 = 0;
			int year3 = 1;
			for (int i = 0; i < year - 1; i++) {
				int temp1 = year1;
				int temp2 = year2;
				int temp3 = year3;

				year1 = temp3;
				year2 = temp1;
				year3 = temp3 + temp2;
			}
			int num = year1 + year2 + year3;
			if (year == 0) {
				break;
			} else {
				System.out.println(num);
			}
		}
	}
}